#pragma once
#include "rtsp.h"
#include <mutex>

namespace jlh
{
	class RtspConnection;
	class RtspPusher : public Rtsp
	{
	public:
		static std::shared_ptr<RtspPusher> Create();
		virtual ~RtspPusher();

		int OpenUrl(std::string& url, int msec = 600000);
		void Close();
		bool IsConnected();

		void AddSession(MediaSession* session);
		void RemoveSession(MediaSessionId session_id);

		void PushVideo(const uint8_t* data, uint32_t size, uint32_t timestamp);
		void PushAudio(const uint8_t* data, uint32_t size, uint32_t timestamp);
		bool PushFrame(MediaChannelId channelId, AVFrame frame);

	protected:
		MediaSessionPtr LookMediaSession(MediaSessionId session_id) override;

	private:
		RtspPusher();
		

		std::mutex mutex_;
		std::shared_ptr<RtspConnection> rtsp_conn_;
		std::shared_ptr<MediaSession> media_session_;
	};
}


